package cn.ml.springdemo.annotation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Component
public class F {

    //@Autowired//按类型注入（spring）
    //@Qualifier("person2")//当有两个person类型可以指明用哪个
    @Resource(name = "person2")//默认按名字注入（java）
    private Person person;

    public void say(){
        System.out.println("F.say:"+this.getClass().getName());
        System.out.println("F.say:"+person);
    }
    public void show(){
        System.out.println("show ...f");
    }

    public void myError(){
        throw new RuntimeException("故意抛出的异常?????。。。。");
    }
}
